﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Yunwei.BizLogic;
using Yunwei.IBizLogic;
using Yunwei.Web.Models;

namespace Yunwei.Web.Controllers
{
    public class RestaurantController : Controller
    {
        IFoodService foodService;
        IRestaurantService restaurantService;
        public RestaurantController()
        {
            foodService = new FoodService();
            restaurantService = new RestaurantService();
        }

        public ActionResult Detail(int id)
        {
            var restaurant = restaurantService.Find(id);
            if (restaurant == null || restaurant.Id <= 0)
            {
                return RedirectToAction("Error404", "Home");
            }

            var foods = foodService.FindList(20, "", id, 0, 0, null, null, 1);

            RestaurantViewModel rtvm = new RestaurantViewModel();
            rtvm.Restaurant = restaurant;
            rtvm.Foods = foods.ToList();
            return View(rtvm);
        }
    }
}